package com.speed_run.vo;

import com.alibaba.fastjson.JSON;
import com.speed_run.model.ExerciseData;
import com.speed_run.utils.JwtUtils;
import lombok.Data;

import java.util.Date;

@Data
public class ExerciseVo {
	
    private Integer type;   // 0慢跑 1跑步 2鍛煉 3骑行
    private Float kilometre;
    private Integer calorie;
    private Integer second;
    private Integer step;
    private String target; //目标
    private Integer progress; //完成度
    private String  pace; //配速
    private String token;
    private Long time;

    public ExerciseData getEntity(){
        ExerciseData data = new ExerciseData();
        data.setDate(this.time == null?new Date():new Date(this.time));
        data.setType(this.type);
        data.setCalorie(this.calorie == null?0:this.calorie);
        data.setKilometre(this.kilometre == null? 0:this.kilometre*100);
        data.setMinute(this.second == null?0:this.second);
        data.setStep(this.step == null?0:this.step);
        data.setUserId(JwtUtils.pareseToken(token));
        data.setTarget(this.target);
        data.setProgress(this.progress);
        data.setPace(this.pace); 
        return data;
    }
    
    public static void main(String[] args) {
    	ExerciseVo vo =  new ExerciseVo();
    	vo.setCalorie(1);
    	vo.setKilometre(1f);
    	vo.setPace("13");
    	vo.setProgress(3);
    	vo.setType(1);
    	vo.setToken("eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMDE3MTEyNWZxamcwbTduIn0.IaWtFlhB0ex8zhm6Un71Fydmr1IhYoBQII9CHf6D1tBkYL_R95zXM5U1yjDrsQpY3C6OaR0_xNdIqqPiLRXIkA");
    	System.out.println(JSON.toJSONString(vo));
	}
}
